// pages/uc/my_work/my_work.js
var dmNetwork = require("../../../utils/network.js");
var util = require("../../../utils/util.js");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    tabList: ['技能认证', '职业证书'],
    currentTab: 1,
    show: false,
    list: [
      {
        id:1,
        title: '驾驶证', 
      },
      {
        id:2,
        title: '健康证', 
      },
      {
        id:3,
        title: '学生证', 
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
   onTabChange(e) {
    this.setData({
      currentTab: e.currentTarget.dataset.index
    });
  },
  showPopup() {
    this.setData({ show: true });
  },

  onClose() {
    this.setData({ show: false });
  },
  //获取驾照相关信息
  getInitInfo: function () {
    dmNetwork.get(
      dmNetwork.driving_license,
      {
        dmclient: "weixinxcx",
      },
      (res) => {
        if (res.data.errno == 0) {
          var data = res.data.data;
          this.data.isAllUpload=this.isAllUpload(data)
          // 组件的显示数据初始化
          const driFrontCardImg = `driverLicense.value.frontCardImg`;
          const driBackCardImg = `driverLicense.value.backCardImg`;
          const driName = `driverLicense.inputInfoValue.name`;
          const driIdCard = `driverLicense.inputInfoValue.idCard`;
          const vehiFrontCardImg = `vehicleLicense.value.frontCardImg`;
          const vehiBackCardImg = `vehicleLicense.value.backCardImg`;
          const vehiName = `vehicleLicense.inputInfoValue.name`;
          const vehiIdCard = `vehicleLicense.inputInfoValue.idCard`;
          const cardNum = `carNumber.value.frontCardImg`;
          //将要提交的数据初始化
          this.data.submitDriverLicense.driver_license_front=data.driver_license_front;
          this.data.submitDriverLicense.driver_license_back=data.driver_license_back;
          this.data.submitDriverLicense.driver_license_real_name=data.driver_license_real_name;
          this.data.submitDriverLicense.driver_license_no=data.driver_license_no;

          this.data.submitVehicleLicense.vehicle_license_front=data.vehicle_license_front;
          this.data.submitVehicleLicense.vehicle_license_back=data.vehicle_license_back;
          this.data.submitVehicleLicense.license_plate_no=data.license_plate_no;
          this.data.submitVehicleLicense.vehicle_owner=data.vehicle_owner;

          this.data.submitCarNumber.other_license_no=data.other_license_no;
          this.data.submitCarNumber.other_license_image=data.other_license_image;
          this.setData({
            [driFrontCardImg]: data.driver_license_front,
            [driBackCardImg]: data.driver_license_back,
            [driName]: data.driver_license_real_name,
            [driIdCard]: data.driver_license_no,
            [vehiFrontCardImg]: data.vehicle_license_front,
            [vehiBackCardImg]: data.vehicle_license_back,
            [vehiName]: data.vehicle_owner,
            [vehiIdCard]: data.license_plate_no,
            [cardNum]: data.other_license_image,
            otherCarNumber:data.other_license_no
          });
        }
      }
    );
  },
  //去掉空格
  trim(str){
    const num=str.replace(/\s*/g, '');
    return num;
  },
  toast({ title, icon = "none", duration = 2000 }) {
    wx.showToast({
      title,
      icon,
      duration
    });
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});
